import {
  reactive,
  onMounted,
  onBeforeUnmount,
} from 'vue'
export default function () {
  let location = reactive({
    x: '?',
    y: '?'
  })

  function getLocation(event) {
    location.x = event.pageX
    location.y = event.pageY
    console.log(location)
  }

  onMounted(() => {
    window.addEventListener('click', getLocation)
  })

  onBeforeUnmount(() => {
    window.removeEventListener('click', getLocation)
  })

  return location
}
